#pragma once
#include "platform.h"
#include <string>
class GrfNode;
class GrfFile;
class GrfTreeNode;


class GrfEntry
{
public:
	std::string m_filename;
	uint8_t flags;
	uint32_t size; // real size
	uint32_t len; // compressed size
	uint32_t len_aligned; // storage size in grf
	uint32_t pos; // offset in grf

public:
	GrfEntry::GrfEntry() : m_filename(""), flags(0), size(0), len(0), len_aligned(0), pos(0) { }
	const char* GrfEntry::filename() const { return m_filename.c_str(); }
	uint32_t GrfEntry::get_size() const { return size; }
	uint8_t GrfEntry::storage_flags() const { return flags; }
	uint32_t GrfEntry::storage_size() const { return len_aligned; }
	uint32_t GrfEntry::storage_pos() const { return pos; }
};


class GrfNode : public GrfEntry
{
public:
	GrfNode* prev;
	GrfNode* next;
	GrfFile* parent;
	GrfTreeNode* tree_parent;

public:
	GrfNode::GrfNode() : prev(NULL), next(NULL), parent(NULL), tree_parent(NULL) { }
	GrfNode::~GrfNode() { if( next != NULL ) next->prev = prev; if( prev != NULL ) prev->next = next; }
	GrfNode* GrfNode::get_prev() const { return prev; }
	GrfNode* GrfNode::get_next() const { return next; }
	GrfTreeNode* GrfNode::get_tree() const { return tree_parent; }
};
